Documentation of type_safe

Project Status Build Status Build status Download

type_safe provides zero overhead abstractions that use the C++ type system to prevent bugs.

Zero overhead abstractions here and in following mean abstractions that have no cost with optimizations enabled, but may lead to slightly lower runtime in debug mode, especially when assertions for this library are enabled.

The library features cannot really explained in the scope of this readme, I highly suggest that you check out the first and second blog post and the examples.


Improved built-in types

Vocabulary types

Optional & Variant

Type safe building blocks


Header-only, just copy the files in your project. You need to add the type_safe include directory to your include path as well as make debug_assert.hpp available. The repository is included as git submodule, simply run git submodule update --init and add external/debug_assert to the include path. You also need to enable C++11.

Behavior can be customized with the following macros:

If you’re using CMake there is the target type_safe available after you’ve called add_subdirectory(path/to/type_safe). Simply link this target to your target and it will setup everything automagically. For convenience the macros are also mapped to CMake options of the same name.


This project is greatly supported by my patrons. In particular thanks to the individual supporters:

And big thanks to the main contributors as well: